package com.neusoft.elmboot.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.Business;

@Mapper
public interface BusinessMapper {
	@Select("select * from business where orderTypeId=#{orderTypeId} order by businessId")
	public List<Business> listBusinessByOrderTypeId(Integer orderTypeId);

	@Select("select * from business where businessId=#{businessId}")
	public Business getBusinessById(Integer businessId);

	@Select("select * from business where businessName like concat('%',#{0},'%') union select * from business where businessAddress like concat('%',#{0},'%')")
	public List<Business> listBusinessByname(String bname);
	
	@Update("update business set sale=#{sale+1} where businessId=#{businessId}")
	public int updateBusinessSale(Business business);
	
	@Insert("insert into business values(#{businessId},#{businessName},#{businessAddress},null,null,#{orderTypeId},null,null,#{password})")
	public int addBusiness(Business business);

	@Select("select * from business where businessId=#{businessId} and businesspassword=#{businesspassword}")
	public Business getBusinessByIdByPass(Business business);

	@Update("update business set businessName=#{businessName},businessAddress=#{businessAddress},businessExplain=#{businessExplain},orderTypeId=#{orderTypeId},starPrice=#{starPrice},deliveryPrice=#{deliveryPrice},remarks=#{remarks} where businessId=#{businessId}")
	public int updateBusiness(Business business);

	@Update("update business set businesspassword=#{businesspassword} where businessId=#{businessId}")
	public int updateBusinessPassword(Business business);
	
	@Select("select * from business where businessId=#{businessId}")
	public List<Business> listBusinessAddressBybusinessId(Integer businessId);
}